package com.sxc.study;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

public class RecyclerViewActivity extends AppCompatActivity {

    private static final String TAG = "RecyclerViewActivity";

    private RecyclerView recycler_view;
    private MAdapter adapter;
    private CustomerLayoutManager layoutManager;

    private List<String> datas = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view);
        recycler_view = findViewById(R.id.recycler_view);
        recycler_view.setLayoutManager(layoutManager = new CustomerLayoutManager());
        for (int i = 0; i < 100; i++) {
            datas.add("第" + i + "项");
        }

        Log.d(TAG, "onCreate: " + datas.size());
        recycler_view.setAdapter(adapter = new MAdapter(datas));
        recycler_view.addItemDecoration(new DividerItemDecoration(this, RecyclerView.VERTICAL));

    }
}
